define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'alarm/index',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 80, search: false},
                    {field: 'name', title: '姓名'},
                    {field: 'id_card', title: '身份证号'},
					{field: 'mobile', title: '手机号'},
                    {field: 'check_result', search: 'select', selectList: ["阴性","阳性"], title: '核酸检测结果', templet: function (d) {
                            if (d.check_result === 1) {
                                return '<div class="layui-table-cell laytable-cell-1-0-8" style="background-color: red;color: #fff;">阳性</div>';
                            }
                            return '<div class="layui-table-cell laytable-cell-1-0-8">阴性</div>';
                        }},
                    {field: 'create_time', title: '提交时间', search: 'range'},
                ]],
            });

            ea.listen();
        },
        temperature_index: function () {
            ea.table.render({
                init: {
                    table_elem: '#currentTable',
                    table_render_id: 'currentTableRenderId',
                    index_url: 'alarm/temperature_index',
                },
                toolbar: ['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 100, search: false},
                    {field: 'name', title: '姓名'},
                    {field: 'id_card', title: '身份证号'},
					{field: 'mobile', title: '手机号'},
                    {field: 'temperature', title: '体温（℃）', templet: function (d) {
                            if (d.temperature > 37.3) {
                                return '<div class="layui-table-cell laytable-cell-1-0-8" style="background-color: red;color: #fff;">' + d.temperature + '</div>';
                            }
                            return '<div class="layui-table-cell laytable-cell-1-0-8">' + d.temperature + '</div>';
                        }},
                    {field: 'create_time', title: '提交时间', search: 'range', templet: ea.table.date},
                ]],
            });

            ea.listen();
        },
    };
    return Controller;
});